package aop.xyz.myapp;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppCtxFactory {
	private static final AppCtxFactory appCtxFactory = new AppCtxFactory();
	private ApplicationContext ctx = null;

	public static AppCtxFactory getInstance() {
		return appCtxFactory;
	}

	public ApplicationContext getAppContext() {
		
		// it was double checked.
		if (ctx == null) {
			synchronized (this) {
				if (ctx == null) {
					String resPath = "classpath*:*.ctx.xml";
					ctx = new ClassPathXmlApplicationContext(resPath);
				}
			}
		}

		return ctx;
	}
}
